<script src="/validation/jquery.js"></script>
<script src="/validation/jquery.validate.min.js"></script>
<script src="/validation/messages_zh.js"></script>

<script>

    /*
     *  验证器
     */
    $.validator.setDefaults({
        submitHandler: function() {
            roleSubmit();
        }
    });
    jQuery.validator.addMethod("isMobile", function(value, element) {
        var length = value.length;
        // var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
        // return this.optional(element) || (length == 11 && mobile.test(value));
        return this.optional(element) || (length == 11 );
    }, "请正确填写手机号码");
    $().ready(function() {
        $('[form="submit"]').validate({
            rules: {
                //账号、用户名
                user_name: {required: true,minlength: 2},
                //密码
                password:{required: true,},
                //确认密码
                password2:{required: true,equalTo:"[name='password']"},
                //电子邮箱
                email:{required: true, email: true,},
                //角色名称
                role_name:{required: true, minlength: 2},
                //会员等级名称
                level_name:{required: true},
                //会员额度
                amount:{required: true,number:true},
                //折扣率
                discount:{required: true,range:[0,100]},
                //会员昵称
                nickname:{required: true,},
                //手机号
                mobile:{required: true, isMobile :true},
                //consignee收货人姓名
                consignee:{required: true} ,
                //province 省
                province:{required: true} ,
                // city 市
                city:{required: true} ,
                name:{ required:true,},
                //district 县、区
                district:{required: true},
                //address 详细地址
                address:{required: true},
                //zipcode 邮政编码
                zipcode:{required: true},
                //remark 提现备注
                remark:{required: true},
                //mobile_code
                mobile_code:{required: true},
            },
            messages: {
                user_name: { minlength: "用户名必需由两个或两个以上组成"},

                mobile:{isMobile:"请输入正确格式手机号"},
            }
        });
    });
</script>